#include <bits/stdc++.h>
using namespace std;
#define ar array
#define ll long long
const int MAX_N = 1e5 + 1;
const ll INF = 1e9;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,m, k;
cin >> n >> m >> k;
vector<int> row_arr(n+10, 0);
vector<int> row_arr_time(n+10, 0);
vector<int> col_arr(m+10, 0);
vector<int> col_arr_time(m+10, 0);
int time = 0;
while (k--) {
time++;
int flag, c, a;
cin >> flag >> c >> a;
if (flag == 1) {
row_arr[c] = a;
row_arr_time[c] = time;
} else {
col_arr[c] = a;
col_arr_time[c] = time;
}
}
for (int r = 1; r <= n; r++) {
for (int c = 1; c <= m; c++) {
if (row_arr_time[r] == 0 && col_arr_time[c] == 0) {
cout << 0 << " ";
} else if (row_arr_time[r] > col_arr_time[c]) {
cout << row_arr[r] << " ";
} else if (col_arr_time[c] > row_arr_time[r]) {
cout << col_arr[c] << " ";
}
}
cout << "\n";
}
}
1621A - Stable Arrangement of Rooks | 472A - Design Tutorial Learn from Math |
1368A - C+= | 450A - Jzzhu and Children |
546A - Soldier and Bananas | 32B - Borze |
1651B - Prove Him Wrong | 381A - Sereja and Dima |
41A - Translation | 1559A - Mocha and Math |
832A - Sasha and Sticks | 292B - Network Topology |
1339A - Filling Diamonds | 910A - The Way to Home |
617A - Elephant | 48A - Rock-paper-scissors |
294A - Shaass and Oskols | 1213A - Chips Moving |
490A - Team Olympiad | 233A - Perfect Permutation |
1360A - Minimal Square | 467A - George and Accommodation |
893C - Rumor | 227B - Effective Approach |
1534B - Histogram Ugliness | 1611B - Team Composition Programmers and Mathematicians |
110A - Nearly Lucky Number | 1220B - Multiplication Table |
1644A - Doors and Keys | 1644B - Anti-Fibonacci Permutation |